package DDL;

import java.io.File;

public class RenameTable {  //表的重命名
	public static boolean renameTable(String dataBaseName, String oldName,String newName) {
		File oldFile1 = new File("D:\\database\\" + dataBaseName + "\\"  //旧文件及新文件名
				+ oldName + ".dbf");
		File newFile1 = new File("D:\\database\\" + dataBaseName + "\\"
				+ newName + ".dbf");
		File oldFile2 = new File("D:\\database\\" + dataBaseName + "\\"
				+ oldName + ".dat");
		File newFile2 = new File("D:\\database\\" + dataBaseName + "\\"
				+ newName + ".dat");
		if(!oldFile1.exists()){//||!oldFile2.exists()  找不到旧文件，返回错误
			return false;
		}
		else {
			oldFile1.renameTo(newFile1); //.dat和.dbf文件更名
			oldFile2.renameTo(newFile2);
		}	
		return true;	
	}

}
